

*     ***************************************************************** * 
*     ***************************************************************** * 
*       File-Name:      master.do                                       * 
*       Date:           October 7, 2016                                    * 
*       Author:         Gschwend                                        * 
*       Purpose:      	OUP book, chapter on Strategic Voting           * 
* 	    Input File:                                                     * 
*       Data Output:                                                    *              
*       Machine:        office computer                 				* 
*     ****************************************************************  * 
*     ****************************************************************  * 


* You need to dowload the following ado's before running this code!!!!!!
* - clarify - 
* - fre - 
* - esttab, estout -

* Last changes: 




clear
set more off
version 14.2


**********************************************
* Specify your own local path to the dropbox *
**********************************************


* Thomas G.'s local (office) path:
* local path /Users/gschwend/Dropbox/Andre/OUP multilevel electoral behavior book/chapter 6/replication/


* Thomas G.'s local (Air) path:
 local path /Users/thomasgschwend/Dropbox/Andre/OUP multilevel electoral behavior book/chapter 6/replication/
 
 
cd "`path'/"

* ********************************************************************* * 
*       prepare parties data for merge               
* 	    Input File:     parties.dta                                   
*       Data Output:    parties_merge.dta                                        
* ********************************************************************  * 

do parties



* ********************************************************************* * 
*       get district-level winners of first round who 
*       advance to second for France (national)      
* 	    Input Files:    PTY_FRA_NAT_01_11_2012_ResultsDistrictsPACA_IDF_Redux       
*       Data Output:    partycodes.dta                                                       
* ********************************************************************  * 

do partycodes


* ********************************************************************* * 
*       get individual election studies and aggregate them per country               
* 	    Input File:                                       
*       Data Output:    aggregate.dta                                        
* ********************************************************************  * 

do getSpainDataset
do getGermanDataset
do getFranceDataset

do aggregate




* ********************************************************************* * 
*       Performs basic recoding of variables               
* 	    Input File:     aggregate.dta                                    
*       Data Output:    recode.dta                                        
* ********************************************************************  * 

do data0  



* ********************************************************************* * 
*       Recoding of variables, Analysis regional level, 
*       code for Fig 6.1 & 6.2 and Table 6.1	              
* 	    Input File:     recode.dta                                    
*       Data Output:    party.dta  & individual.dta                                      
* ********************************************************************  * 

do recode0




* ********************************************************************* * 
*       Partylevel Analysis, Table 6.2                
* 	    Input File:     individual.dta                                    
*       Data Output:                                           
* ********************************************************************  * 

do partylevel



* ********************************************************************* * 
*       individual analysis, Table 6.3 & 6.4, Figure 6.3           
* 	    Input File:     individual.dta                                    
*       Data Output:                                           
* ********************************************************************  * 

do individual



* ********************************************************************* * 
*       Bavaria panel data to study strategic balancing   
*                       Table 6.5 & Figure 6.4	           
* 	    Input File:     SURV_GER_Bavaria_5wave_cleaned_SurveyData.dta			                                         
*       Data Output:    panel.dta                                         
* ********************************************************************  * 

do panel



* ********************************************************************* * 
*       Remove dta-files that have been left behind           
* 	    Input File:     			                                         
*       Data Output:                                             
* ********************************************************************  * 

do remove



